package com.xiaoa.gossip.cluster.command;

import lombok.Data;

import java.util.Date;
import java.util.Map;
import java.util.Set;

/**
 * 集群节点信息
 *
 * @author luokaichuang
 * @time 2020/5/7
 */
@Data
public class NodeState  {

    // 节点id
    private String id;

    /**
     * 节点状态 0 刚启动  1:正在初始化  2:正常服务  3:暂停服务  4:准备关闭  5:关闭
     **/
    public static final int NODE_STATE_START = 0;
    public static final int NODE_STATE_INIT = 1;
    public static final int NODE_STATE_RUN = 2;
    public static final int NODE_STATE_SUSPEND = 3;
    public static final int NODE_STATE_ABOUT_TO_CLOSE = 4;
    public static final int NODE_STATE_CLOSE = 5;

    public static final int NODE_STATE_P_FAIL= 6;
    public static final int NODE_STATE_FAIL= 7;
    private Integer state;

    // 节点名字
    private String name;

    // 当前节点端口
    private Integer port;

    // 当前节点ip
    private String ip;

    /**
     * hash 分配slot
     **/
    private Set<Integer> slot;

    // 启动时间
    private Date startTime;

    // 当前数据版本
    private Long dataVersion;

    /**
     *供节点使用的元数据
     **/
    private Map<String,String>  metadata;

    @Override
    public Object clone() throws CloneNotSupportedException {
        return super.clone();
    }

}
